#coding:utf-8
__author__ = 'wwj'
from datetime import *
from celery.schedules import crontab
from kombu import Queue
import urllib
# BROKER_URL = 'mongodb://coderhuang:sdfsdc323dd@47.75.39.50:27017/celery'
BROKER_URL = 'amqp://guest:guest@localhost:5672/localvhost'
CELERY_RESULT_BACKEND = 'mongodb://coderhuang:sdfsdc323dd@47.75.39.50:27017/backend'

CELERY_DEFAULT_EXCHANGE_TYPE = 'topic' # 默认的交换类型是topic
CELERY_QUEUES = (
    Queue('janpan', routing_key='janpan.#'), # 路由键以“task.”开头的消息都进default队列
    Queue('hongkong', routing_key='honekong.#'), # 路由键以“task.”开头的消息都进default队列
    Queue('dmm', routing_key='dmm.#'), # 路由键以“web.”开头的消息都进web_tasks队列
    Queue('xvideo',routing_key='xvideo#'), # 路由键以“web.”开头的消息都进web_tasks队列
)
# task_default_routing_key = 'task.default'
# CELERY_DEFAULT_EXCHANGE = 'tasks' # 默认的交换机名字为tasks

# CELERY_DEFAULT_ROUTING_KEY = 'task.default'

# CELERY_TASK_SERIALIZER = 'msgpack' # 任务序列化和反序列化使用msgpack方案

CELERY_RESULT_SERIALIZER = 'json' # 读取任务结果一般性能要求不高，所以使用了可读性更好的JSON

CELERY_TASK_RESULT_EXPIRES = 60 * 60 * 24 * 2# 任务过期时间，不建议直接写86400，应该让这样的magic数字表述更明显

CELERY_TIMEZONE = 'Asia/Shanghai'

CELERYD_MAX_TASKS_PER_CHILD = 100

# CELERY_ACCEPT_CONTENT = ['json', 'msgpack'] # 指定接受的内容类型
# CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml']
# CELERYBEAT_SCHEDULE = {
#     'xvideo': {
#        'task': 'tasks.xvideo',
#        'schedule': crontab(minute=10),
#        'args': (),
#        "options":{'queue':'xvideo'}
#     },
#
# }
